<template>
  <div class="member-order-detail" v-if="order">
    <!-- 头部 -->
    <DetailAction :order="order"></DetailAction>
    <!-- 进度 -->
    <DetailStep :order="order"></DetailStep>
    <!-- 物流 -->
    <suspense>
      <template #default>
        <DetailLogistics
          v-if="[3, 4, 5].includes(order.orderState)"
          :order="order"
        ></DetailLogistics>
      </template>
      <template #fallback>
        <div class="loading">loading</div>
      </template>
    </suspense>

    <!-- 订单信息 -->
    <DetailInfo :order="order"></DetailInfo>
  </div>
</template>

<script>
import { ref } from 'vue'
import DetailAction from './components/detail-action.vue'
import DetailStep from './components/detail-step.vue'
import DetailLogistics from './components/detail-logistics.vue'
import { findOrderDetail } from '@/api/order'
import { useRoute } from 'vue-router'
import DetailInfo from './components/detail-info.vue'
export default {
  name: 'MemberDetail',
  components: { DetailAction, DetailStep, DetailLogistics, DetailInfo },
  setup () {
    const order = ref(null)
    const route = useRoute()
    findOrderDetail(route.params.id).then((data) => {
      order.value = data.result
    })
    return { order }
  }
}
</script>

<style scoped lang="less">
.member-order-detail {
  background-color: #fff;
  height: 100%;
}
</style>
